<%@ page language="java" import="com.alibaba.fastjson.JSONArray" pageEncoding="UTF-8" %>
<%@ page import="com.alibaba.fastjson.JSONObject" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%--获取银行信息接口--%>
<%
    String gysbmdxwb = Util.null2String(request.getParameter("gysbmdxwb"));
    JSONObject dataJson = new JSONObject();
    try {
        JSONArray itemList = new JSONArray();
        RecordSet rs = new RecordSet();
        rs.executeQuery("select id,fktj from uf_sapgyszsj where gysbm=?", gysbmdxwb);
        rs.next();
        String mainid = Util.null2String(rs.getString("id"));
        String fktj = Util.null2String(rs.getString("fktj"));
        dataJson.put("fktj", fktj);
        rs.executeQuery("select id,rownum from uf_sapgyszsj_dt1 where mainid=?", mainid);
        while (rs.next()) {
            JSONObject itemJson = new JSONObject();
            itemJson.put("mxid", Util.null2String(rs.getString("id")));
            String rownum = Util.null2String(rs.getString("rownum"));
            itemJson.put("rownum", autoGenericCode(rownum, 4));
            itemList.add(itemJson);
        }
        dataJson.put("item", itemList);
    } catch (Exception e) {
        e.printStackTrace();
    }
    out.print(dataJson.toJSONString());
%>

<%!
    private static String autoGenericCode(String code, int num) {
        return String.format("%0" + num + "d", Integer.parseInt(code));
    }
%>


